<?php

	session_start();
	if($_SESSION["username"] == "")
	{
		header("location:login.php");
		exit();
	}

	include 'connectDB.php';

	$strSQL = "SELECT * FROM tbl_user WHERE username = '".$_SESSION["username"]."'  ";
	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
	$objResult = mysql_fetch_array($objQuery);
?>
<html>
<head>
<title>Welcome to Merchant Manage.</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="header">
	<div class="logo">Merchant Manage</div>
	<div class="user" >Hi !	 <?=$objResult["username"];?><br><a href="logout.php" name="logout" id="logout" />logout</a></div>
</div>	
	
<div id="container">
	<a href="dashboard.php">dashboard</a> > <a href="">merchant</a>
	<br>
	<br>	
	<a href="addMerchant.php">+ add merchant</a>
	<br>
	<br>
	<div class="frmAddMer">
	  <table border="0" cellpadding="10" cellspacing="0" width="1000">
	  	<tr>
	  		<td >MerID</td>
	  		<td>MerName</td>
	  		<td>Description</td>
	  		<td>Longtitude</td>
	  		<td>Latitude</td>
	  		<td>Date</td>
	  		<td>E</td>
	  		<td>D</td>
	  	</tr>
	  	
	 <?php 
	 
	 	$strSQL = "SELECT * FROM tbl_merchant ORDER BY date DESC";
	 	$objQuery = mysql_query($strSQL);
		
		while ($objResult = mysql_fetch_array($objQuery)) 
		{
			
	 ?>
	  	
	  	<tr>
	  		<td><?php echo $objResult['mer_id'];?></td>
	  		<td><?php echo $objResult['mer_name'];?></td>
	  		<td><?php echo $objResult['description'];?></td>
	  		<td><?php echo $objResult['longtitude'];?></td>
	  		<td><?php echo $objResult['latitude'];?></td>
	  		<td><?php echo $objResult['date'];?></td>
	  		<td><a href="JavaScript:if(confirm('Comfirm Edit Data?')==true){window.location='EditMerchant.php?MerID=<?=$objResult["mer_id"];?>';}">Edit</a></td>
	  		<td><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='DeleteMerchant.php?MerID=<?=$objResult["mer_id"];?>';}">Delete</a></td>
	  	</tr>
	<?php
		}
	?>
	  </table>
	<?php
	  mysql_close();
	?>
	</div>
</div>	
	
</body>
</html>